package com.nep.NEPM.controller;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;
import javafx.scene.control.*;
import com.nep.NEPM.controller.AdminViewController.AQIData;

public class AdminAQIController {
    // 绑定FXML元素
    @FXML private LineChart<String, Number> trendChart;
    @FXML private TableView<AQIData> dataTable;
    @FXML private ComboBox<String> areaFilter;
    @FXML private DatePicker dateFilter;
    @FXML private Label statusLabel;

    // 动态样式控制方法
    public void initialize() {
        // 表格行样式控制
        dataTable.setRowFactory(tv -> {
            TableRow<AQIData> row = new TableRow<>();
            row.itemProperty().addListener((obs, oldVal, newVal) -> {
                if (newVal != null) {
                    // 根据AQI值动态设置行背景色
                    if (newVal.getCount() > 150) {
                        row.setStyle("-fx-background-color: #ffdddd;");
                    } else {
                        row.setStyle("");
                    }
                }
            });
            return row;
        });

        // 状态标签动态样式
        statusLabel.textProperty().addListener((obs, oldVal, newVal) -> {
            if (newVal.contains("异常")) {
                statusLabel.setStyle("-fx-text-fill: #e74c3c;");
            } else {
                statusLabel.setStyle("-fx-text-fill: #27ae60;");
            }
        });
    }

    // 其他业务方法...
    @FXML
    private void showAuditView() {
        // 实现审核视图逻辑
    }

    @FXML
    private void loadData() {
        // 数据加载逻辑
    }

    public void showAlertView(ActionEvent event) {
    }
}